<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class AddChannelStatKeepTable extends Migration
{
    protected $connection = 'stat';

    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('stat_daily_keep', function (Blueprint $table) {
            $table->char('channel', 10)->default('')->comment('注册渠道')->after('stat_type');
            $table->unsignedInteger('total_num')->default(0)->comment('注册人数');
            $table->unsignedInteger('keep_1_num')->default(0)->comment('1日留存人数');
            $table->unsignedInteger('keep_2_num')->default(0)->comment('2日留存人数');
            $table->unsignedInteger('keep_3_num')->default(0)->comment('3日留存人数');
            $table->unsignedInteger('keep_7_num')->default(0)->comment('7日留存人数');
            $table->unsignedInteger('keep_15_num')->default(0)->comment('15日留存人数');
            $table->unsignedInteger('keep_30_num')->default(0)->comment('30日留存人数');
            $table->index('stat_type', 'stat_type');
            $table->index('channel', 'channel');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('stat_daily_keep', function (Blueprint $table) {
            //
        });
    }
}
